package com.kotiln.lgc.lib_network.logic.dao

import android.util.Log
import androidx.lifecycle.liveData
import com.kotiln.lgc.lib_network.HttpManager
import kotlinx.coroutines.Dispatchers
import kotlin.coroutines.CoroutineContext

/**
 *@fileName Repository
 *@date2021/1/25  18:05
 *@author Repository$
 *@describe TODO
 *@desc 仓库层 Jetpack
 */
object Repository {

   /* fun queryWeather(query:String)= fire(Dispatchers.IO) {
        val weather=HttpManager.queryWeather(query)
        Log.i("placeResPonse",weather.toString())
        if(weather.status=="ok"){
            val places=weather.places
            Result.success(places)
        }else{
            Result.failure(RuntimeException("response status is ${weather.status}"))
        }
    }

    private fun <T> fire(context: CoroutineContext, block:suspend()->Result<T>)= liveData<Result<T>>(context){
        val result=try {
            block()
        } catch (e:Exception){
            Result.failure<T>(e)
        }
        emit(result)
    }*/
}